//
//  SNStravaShare.swift
//  project
//
//  Created by 黄建华 on 2018/7/26.
//  Copyright © 2018年 黄建华. All rights reserved.
//

import UIKit
import Foundation
class SNStravaShare: NSObject {
    override init() {
        super.init()
        stravaShare()
    }
}

func stravaShare() {
    print("show strava share>>>>>")
    let token = SN_PublicClassSwift?.showStravaToken
    let client = HTTPClientBuilder.client(withToken:token!, debug: true)
    let upLoad = UploadAPI(client: client)
    let path  = SN_PublicClassSwift?.stravaPathString
    let stravaUrl =  NSURL(fileURLWithPath: path!)
    
    upLoad.upload(file: stravaUrl as URL, withFilename: "GetFitPro", withDataType:DataType(rawValue: "gpx")!, withActivityType: UploadActivityType.run, withName:"Share Form GetFitPro", withDescription: SN_PublicClassSwift?.shareDescription, isPrivate: false, hasTrainer: false, isCommute: false, withExternalID: "test.gpx").execute { (result) in
        
        print("upload rusult >>> \(result)")

        NotificationCenter.default.post(name: NSNotification.Name(rawValue: "stravaShareFinish"), object:nil)
    }
    
}
